<template>
  <div>

    <!-- <el-divider></el-divider> -->
    <template>
      <el-table :data="tableDate" stripe style="width: 100%">
        <el-table-column align="center" label="头像" width="180">
          <template slot-scope="scope">
            <img :src="scope.row.img" width="80px" />
          </template>
        </el-table-column>
        <el-table-column prop="shoujihao" align="center" label="手机号">
        </el-table-column>
        <el-table-column prop="xingbie" align="center" label="性别" width="130">
        </el-table-column>
        <el-table-column prop="shengri" align="center" label="生日" width="200">
        </el-table-column>
        <el-table-column prop="youxiang" align="center" label="邮箱">
        </el-table-column>
        <!-- 操作栏 -->
        <el-table-column align="center" width="260px" label="操作">
          <template slot-scope="scope">
            <el-button @click="
              $router.push('/home/administrator-update/' + scope.row.id)
            " size="small" type="warning" icon="el-icon-edit-outline" circle></el-button>
            <el-button size="small" type="danger" icon="el-icon-delete" circle @click="open(scope.row)"></el-button>
          </template>
        </el-table-column>
      </el-table>
    </template>
  </div>
</template>

<script>
import httpApi from "@/myaxios";
export default {
  data() {
    return {
      tableDate: [],
    };
  },

  methods: {
    // 删除管理人员功能
    open(user) {
      console.log("111", user);
      this.$confirm(`此操作将永久删除<${user.shoujihao}>, 是否继续?`, "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          const id = parseInt(user.id);
          httpApi.BackUser.deleteById(id).then((res) => {
            // console.log("点击删除", res);
            this.$message({
              type: "success",
              message: "删除成功!",
            });
            this.cha();
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    // 查询所有管理人员

    cha() {
      httpApi.BackUser.queryAll().then((res) => {
        // console.log(res);
        this.tableDate = res.data;
        console.log(this.tableDate);
      });
    },
  },
  // 初始化加载

  mounted() {
    this.cha();
  },
};
</script>

<style lang="scss">
.el-form {
  width: 412px;
}
</style>
